home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_kernel_source / KERNEL / PANIC.C < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  82 lines

  1. /*
  2.  *  linux/kernel/panic.c
  3.  *
  4.  *  Copyright (C) 1991, 1992  Linus Torvalds
  5.  */
  6.  
  7. /*
  8.  * This function is used through-out the kernel (including mm and fs)
  9.  * to indicate a major problem.
  10.  */
  11. #include <linux/sched.h>
  12. #include <linux/delay.h>
  13. #include <linux/reboot.h>
  14. #include <linux/init.h>
  15. #include <linux/sysrq.h>
  16. #include <linux/interrupt.h>
  17.  
  18. #ifdef __alpha__
  19. #include <asm/machvec.h>
  20. #endif
  21.  
  22. asmlinkage void sys_sync(void);    /* it's really int */
  23. extern void unblank_console(void);
  24. extern int C_A_D;
  25.  
  26. int panic_timeout = 0;
  27.  
  28. void __init panic_setup(char *str, int *ints)
  29. {
  30.     if (ints[0] == 1)
  31.         panic_timeout = ints[1];
  32. }
  33.  
  34. NORET_TYPE void panic(const char * fmt, ...)
  35. {
  36.     static char buf[1024];
  37.     va_list args;
  38.  
  39.     va_start(args, fmt);
  40.     vsprintf(buf, fmt, args);
  41.     va_end(args);
  42.     printk(KERN_EMERG "Kernel panic: %s\n",buf);
  43.     if (current == task[0])
  44.         printk(KERN_EMERG "In swapper task - not syncing\n");
  45.     else if (in_interrupt())
  46.         printk(KERN_EMERG "In interrupt handler - not syncing\n");
  47.     else
  48.         sys_sync();
  49.  
  50.     unblank_console();
  51.  
  52. #ifdef __SMP__
  53.     smp_send_stop();
  54. #endif
  55.     if (panic_timeout > 0)
  56.     {
  57.         /*
  58.           * Delay timeout seconds before rebooting the machine. 
  59.          * We can't use the "normal" timers since we just panicked..
  60.           */
  61.         printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
  62.         mdelay(panic_timeout*1000);
  63.         /*
  64.          *    Should we run the reboot notifier. For the moment Im
  65.          *    choosing not too. It might crash, be corrupt or do
  66.          *    more harm than good for other reasons.
  67.          */
  68.         machine_restart(NULL);
  69.     }
  70. #ifdef __sparc__
  71.     printk("Press L1-A to return to the boot prom\n");
  72. #endif
  73. #ifdef __alpha__
  74.     if (alpha_using_srm)
  75.         halt();
  76. #endif
  77.     sti();
  78.     for(;;) {
  79.         CHECK_EMERGENCY_SYNC
  80.     }
  81. }
  82.